package com.lll.simple.rpc.protocol.serialization;

import com.alibaba.fastjson.JSON;

import java.io.IOException;

/**
 * @Author: liull
 * @Description: 基于fastjson
 * @Date: Created in 14:34 2021/2/7
 * @Modified By:
 */
public class JsonSerialization implements RpcSerialization {
    @Override
    public <T> byte[] serialize(T obj) throws IOException {
        return JSON.toJSONBytes(obj);
    }

    @Override
    public <T> T deserialize(byte[] data, Class<T> clazz) throws IOException {
        return JSON.parseObject(data, clazz);
    }
}
